import json
import time
import requests
from core import Bot, Enum_Type
from command import register


bot = Bot(auth_key="12345678", qq=1398231927)

while True:
    time.sleep(2)
    fetch = bot.reciveMessage()

    if fetch.messageType == Enum_Type.GroupMessage:
        for item in fetch.messageBody.get("data"):
            message = bot.parseGroupMessage(item)

            # print(message.message_id)

            for key, value in register.items():
                if message is not None and message.text != "" and str(message.text.strip()).startswith(key):
                    register[key]['func'](bot, message)
                    break

            # if message.text != "" and str(message.text).startswith("查询"):
            #     command = "".join(message.text.split("查询")).strip()
            #
            #     r = requests.get("https://cxx.yun7.me/qqapi?qq={}".format(command))
            #     bot.sendGroupMessage(
            #         message.group.group_id, r.text
            #     )
            # bot.recallMessage(message.message_id)
            # bot.sendImageMessage(message.group.group_id, [
            #     "http://f2.leanote.top/5e25c707ab64411ab6008998?e=1624689212&token=T0cw3n7Kjqycn0UzED7QlgeshR7PRU0uMIy3Xz0K:LBUKvzvsjkpNI0mfeGOVkFzuqYw"
            # ])





